package com.zhihua.interview.merge.controller;

import com.zhihua.interview.merge.service.IMergeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")
public class MergeController {

    @Autowired
    public IMergeService iMergeService;

    /**
     * 接收json对象，把order集合中与stock集合中goodsId商品ID相同的记录，number数量相加合并，返回相加后的集合。集合名称为stock
     */

    @PostMapping("/merge")
    @ResponseBody
    @ApiOperation("合并订单")
    public String mergeNumber(String stocks) {
        String stock = iMergeService.mergeNumber(stocks);
        return stock;
    }
}
